package generic;


import java.util.ArrayList;

/**
 * 泛型
 */
public class Generic02 {

    public static void main(String[] args) {


        ArrayList<Dog> arrayList = new ArrayList<Dog>();
        arrayList.add(new Dog("旺财", 10));
        arrayList.add(new Dog("发财", 1));
        arrayList.add(new Dog("小黄", 5));

        //加入不小心添加了一只猫
        //arrayList.add(new Cat("招财猫", 8));

        System.out.println("===使用泛型====");
        for (Dog dog : arrayList) {
            System.out.println(dog.getName() + "-" + dog.getAge());
        }
    }
}
